if(!jsx3.lang.Class.forName("ux.cdb.admin.customer.cusBuilder.AccInfo")) {
	jsx3.lang.Class.defineClass("ux.cdb.admin.customer.cusBuilder.AccInfo",
			ux.megatron.gui.WizardPanel,
			null,
			function (block) {
				/**
				 * instance initializer
				 * @param strName {String} unique name distinguishing this object from all other JSX GUI objects in the JSX application
				 * @param vntLeft {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
				 * @param vntTop {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
				 * @param vntWidth {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
				 * @param vntHeight {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
				 * @param strHTML {String} Text/HTML markup to place in the jsx3.gui.Block instance
				 */
				block.prototype.init = function(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML) {
					//call constructor for super class (the super expects the name of the object and the function that it is an instance of)
					this.jsxsuper(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML);
				};

				block.prototype.initialize = function(msg) {
					this.loaded = true;
					this.builder = this.getAncestorOfType("ux.cdb.admin.customer.cusBuilder.Builder");
					this.wizard = this.getAncestorOfType("ux.megatron.gui.SteppedWizard");
					
					var me = this;
					this.cacheLoaded();
					if(this.builder.editMode == "edit") {
						this.getDescendantsOfType("ux.cdb.admin.dataautomate.GenericDetail")[0].setDataByObject(this.builder.accInfo);
					} else {
/* @JSC :: begin DEBUG */
						jsx3.log('Customer#cusBuilder#AccInfo editMode : NEW');
/* @JSC :: end */
						this.setDefaultValue();
						delete this.buttonStatesArr;
                        this.buttonStates="buttonNext:DISABLED";
						this.wizard.get("buttonNext").disable();
/* @JSC :: begin DEBUG */
						jsx3.log('Customer#cusBuilder#AccInfo set button states : btnNext:DISABLED');
/* @JSC :: end */
					}
/* @JSC :: begin DEBUG */
					console.log('this.builder.baseInfo : ', dwr.util.toDescriptiveString(this.builder.baseInfo, 4));
					console.log('this.builder.studyInfo : ', dwr.util.toDescriptiveString(this.builder.studyInfo, 4));
/* @JSC :: end */
				};
				
				block.prototype.setDefaultValue = function(){
					try{
						this.get('fieldOfCertId').getChild(1).setValue(this.builder.baseInfo.certId);
						this.get('fieldOfOpenAccountName').getChild(1).setValue(this.builder.baseInfo.chnFullName);
						this.get('fieldOfAcctName').getChild(1).setValue(this.builder.baseInfo.chnFullName);
					}catch(e){}
				};
				
				block.prototype.cacheLoaded = function(objEvent) {
					var _cache = ux.cdb.admin.CommonCache.getInstance();
					var blkOpenAccountBank = this.get("blkOpenAccountBank").getChild(1);
					blkOpenAccountBank.setSourceXML(_cache.getCache("CommonCache_AGENT_BANK"));
					setTimeout(function(){
						blkOpenAccountBank.repaint();
					},50);
				}

				block.prototype.onNext = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL) {
					return this.doValidation() ? null : 'NONE';
				}

				block.prototype.onPrev = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL) {
					return null; // return "NONE" to not advance panels
				}

				block.prototype.onRevert = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL) {
					return null; // return "NONE" to not last status
				}

				block.prototype.onCancel = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL) {
					this.getAncestorOfType("ux.cdb.admin.customer.cusBuilder.Builder").onClose();
					return null;
				}
				
				block.prototype.onFinish = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL){
                    if(this.doValidation()) { this.builder.saveBuilder(); }
                    return "NONE";
				};

				block.prototype.onCustomNav = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL) {
					return null; // return "NONE" to not advance panels
				}

				block.prototype.onBeforeShow = function(objWIZARD, objBUTTON, objEVENT, strLASTPANEL) {
					if(!this.getChild(0)) {
						var me = this;
						ux.megatron.Main.loadUIResourceAsync(me, "ux.cdb.admin","ux/cdb/admin/customer/cusBuilder/step3/ui/accInfoContent.xml", me, me.initialize);
					}
					this.setDefaultValue();
					return null; // return "NONE" to not advance panels
				}

				block.prototype.onAfterHide = function(objWIZARD, objBUTTON, objEVENT, strNEXTPANEL) {
					return null; // return "NONE" to not advance panels
				}
				
				block.prototype.onStepJump =  function(objWIZARD,objSTEP,objEVENT,strCURRENTPANEL){
					return this.doValidation() ? null : 'NONE';
				};
				
				block.prototype.displayTip = function(passed) {
                    if(!passed) {
                        var tip = ux.megatron.Main.getServer().getDynamicProperty("@cdb@cusbuilder@TipUnFinishedStep3");
                        this.wizard.getMessageLabel().setText(this._message ? this._message : tip);
                    } else {
                        this.wizard.getMessageLabel().setText("");
                    }
                    return passed;
                };
				
				block.prototype.doValidation = function() {
                    this.detail = this.get("blkStep3");
					var errorMsgs = this.detail.doValidate();
                    this._message = errorMsgs === null ? null : (errorMsgs[0].label ? errorMsgs[0].label + " : " +errorMsgs[0].message : errorMsgs[0].message);
                    if(this._message === null) {
                    	this.cacheDataobj();
	    				return this.displayTip(true);
                    } else {
                        return this.displayTip(false);
                    }
                };
                
                block.prototype.cacheDataobj = function () {
					//populate data
					var dataObj =  this.detail.getDataAsObject();
					
					// save account bank code and name 
					var bankName = this.get('blkOpenAccountBank').getChild(1).getText();
					dataObj.openAccountBankName = bankName;
					
					//console.log(dataObj);
					this.extendObj(this.builder.accInfo, dataObj);
                };
				
				block.prototype.extendObj = function(tarObj,orgObj){
					for(var prop in orgObj){
						tarObj[prop] = orgObj[prop];
					}
					return tarObj;
				};
			}
	);
}
